import unittest
import requests

#测试获取商品列表
#1、登录
# 2、拉取列表
# 3、新建商品
# 4、拉取列表

class BaseShop(unittest.TestCase):
    headers={}

    def login(self,username,pwd):
        login_url="http://www.besttest.cn"
        login_body={
            "username":username,
            "password":pwd
        }
        req=requests.post(login_url,login_body).json()
        token=req.get("token")
        global headers
        headers={"token":token}

    def get_shop_list(self):
        shop_list_url="http://www.besttest.cn/shop/list"
        global headers
        result=requests.get(shop_list_url,headers=headers)
        return result

class TestBaseShop(BaseShop):
    def test_shop_list(self):
        self.login("","")
        shop_list=self.get_shop_list()
        self.assertEqual(shop_list.get("listId"),1)
        self.assertEqual(shop_list.get("listId"), 2)
        self.assertEqual(shop_list.get("listId"), 3)
        self.assertEqual(shop_list.get("listId"), 4)